import { reqCategoryList, reqBannerList, reqFloorList } from "@/api";

export default {
  state: {
    catgoryList: [],
    bannerList: [],
    floorList: [],
  },
  mutations: {
    UPDATA_CATGORYLIST(state, catgoryList) {
      state.catgoryList = catgoryList.slice(0, 15);
    },
    UPDATA_BANNERLIST(state, bannerList) {
      state.bannerList = bannerList;
    },
    UPDATA_FLOORLIST(state, floorList) {
      state.floorList = floorList;
    },
  },
  actions: {
    async getCatgoryList({ commit }) {
      const res = await reqCategoryList();
      if (res.code === 200) {
        commit("UPDATA_CATGORYLIST", res.data);
      }
    },
    async getBannerList({ commit }) {
      const res = await reqBannerList();
      if (res.code === 200) {
        commit("UPDATA_BANNERLIST", res.data);
      }
    },
    async getFloorList({ commit }) {
      const res = await reqFloorList();
      if (res.code === 200) {
        commit("UPDATA_FLOORLIST", res.data);
      }
    },
  },
  getters: {},
};
